package com.kmproject.haifu.mvp.ui.adapter;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.http.imageloader.glide.ImageConfigImpl;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.app.utils.AppUtil;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;
import com.kmproject.haifu.mvp.ui.activity.HouseRentingShowDuanZuListActivity;

import java.io.Serializable;
import java.util.List;

public class HouseRentingShowMainItemNewAdapter extends BaseQuickAdapter<HousePayWayBean, BaseViewHolder> {
    ImageLoader glideImage;
    public HouseRentingShowMainItemNewAdapter( @Nullable List<HousePayWayBean> data) {
        super(R.layout.houserenting_main_item_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HousePayWayBean item) {
        if (glideImage == null) {
            glideImage = ArmsUtils.obtainAppComponentFromContext(mContext).imageLoader();
        }
        glideImage.loadImage(mContext, ImageConfigImpl.builder().url(item.getIcon())
                .imageView(helper.<ImageView>getView(R.id.houserenting_main_item_item_img))
                .build());
        helper.<TextView>getView(R.id.houserenting_main_item_item_txt).setText(item.getName());
        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(mContext, HouseRentingShowDuanZuListActivity.class);
                intent.putExtra("HousePayWayBean",(Serializable) item);
                intent.putExtra("type",item.getCategory());
                mContext.startActivity(intent);
            }
        });
    }
}
